/*
 * StopWatch.h
 *
 *  Created on: Jan 26, 2010
 *      Author: Jamie LaPointe
 */

#ifndef STOPWATCH_H_
#define STOPWATCH_H_

#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>

namespace LinuxStopWatch
{

enum Errors
{
   isTimerNotSet = -2,
   timerNeverStarted = -1,
   noError = 0
};

struct stopWatch
{
   timeval start;
   timeval stop;
};

class StopWatch
{
private:
   bool isTimerSet;
   bool isTimerStopped;
   stopWatch timer;
   const double microsecondsInMilliseconds;
   const double millisecondsInSeconds;
public:
   StopWatch();
   int start();
   int stop();

   //
   // Returns the elapsed CPU time in milliseconds
   //
   double getElapsedTime();
};

}

#endif /* STOPWATCH_H_ */
